﻿using Meiam.System.Core;
using Meiam.System.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //private readonly BaseToOracleERPService _ToOracleERP;
        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder strMsg = new StringBuilder();
            try
            {
                BaseToOracleERPService _ToOracleERP = new BaseToOracleERPService();
                Meiam.System.Core.RedisServer.Initalize();
                //IBaseToOracleERPService _ToOracleERP = new IBaseToOracleERPService();
                string strstart = this.textBox1.Text.ToString();
                string strend = this.txt_end .Text.ToString();
                _ToOracleERP.LoopTl(strstart, strMsg);
                if (string.IsNullOrEmpty(strMsg.ToString()))
                {
                    MessageBox.Show("成功");
                }
                else
                {
                    MessageBox.Show("失败："+ strMsg.ToString());
                }
               
            }
            catch (Exception er)
            {

               
            }
          
        }

        private void button2_Click(object sender, EventArgs e)
        {
            StringBuilder strMsg = new StringBuilder();
            try
            {
                //BaseToOracleERPService _ToOracleERP = new BaseToOracleERPService();
                Meiam.System.Core.RedisServer.Initalize();
                BaseToOracleERPService _ToOracleERP = new BaseToOracleERPService();
                string strjson = this.textBox1.Text.ToString();
                _ToOracleERP.MesReport(strjson, strMsg);
                if (string.IsNullOrEmpty(strMsg.ToString()))
                {
                    MessageBox.Show("成功");
                }
                else
                {
                    MessageBox.Show("失败：" + strMsg.ToString());
                }

            }
            catch (Exception er)
            {


            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            StringBuilder strMsg = new StringBuilder();
            try
            {
                //BaseToOracleERPService _ToOracleERP = new BaseToOracleERPService();
                Meiam.System.Core.RedisServer.Initalize();
                BaseToOracleERPService _ToOracleERP = new BaseToOracleERPService();
                string strstart = this.textBox1.Text.ToString();
                string strend = this.txt_end.Text.ToString();
                _ToOracleERP.LoopTlByDay(strstart, strMsg);
                if (string.IsNullOrEmpty(strMsg.ToString()))
                {
                    MessageBox.Show("成功");
                }
                else
                {
                    MessageBox.Show("失败：" + strMsg.ToString());
                }

            }
            catch (Exception er)
            {
                MessageBox.Show("日投料失败，原因"+ er.Message.ToString());
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Meiam.System.Core.RedisServer.Initalize();
            string strfild = string.Empty;
            string rtn = string.Empty;
            try
            {

                //rtn = RedisServer.Session.HGetAll("9999");
                rtn = RedisServer.Session.HGet("9999", "F375083D-7AB3-4B16-9321-98E0927F1ED7");
                Dictionary<string,string > list = RedisServer.Session.HGetAll("9999");
                string strkey = string.Empty;
                string strvalue = string.Empty;
                foreach (var item in list)
                {
                    strkey= item.Key;
                    strvalue =item.Value;
                }
            }
            catch (Exception er)
            {
                MessageBox.Show("异常，strfild：" +er.Message.ToString());
                return;
            }
            MessageBox.Show("结束，strfild："+ strfild+ ",rtn:"+ rtn);

        }
    }
}
